{extend name="$web_base"/}
{block name="resources"}
<link rel="stylesheet" href="ADDON_NC_ARTICLE_CSS/help.css">
{/block}
{block name="main"}
{php}
	 $article_id = input('article_id', 0); 
	 if($article_id > 0) {
	 	$info = api('Article.Article.getArticleDetail', ['article_id' => $article_id]);
	    $pid = $info['data']['p_id'];
	    $category_id = $info['data']['category_id'];
	 }
	 
 {/php}
<div class="help-box">
	<div class="crumbs-nav-main clearfix">
		<div class="crumbs-nav-item one-level">
	        <a href="javascript:;" class="crumbs-link">首页</a>
	        <i class="icon icon-angle-right"></i>
	    </div>
	    <div class="crumbs-nav-item">
	        <a href="javascript:;">文章中心</a>
	    </div>
    </div>
	<div class="help-menu">
 			 {php}
				 $category_list = api("Article.Article.getCategoryTree", []);
				 if(!$category_id) {
				 	$category_id = input('category_id', 0);
				 }
				 if(!$pid) {
				 	$pid = input('p_id', 0);
				 }
				 if($category_id == 0) {
				 	$category_id = $category_list['data'][0]['category_id'];
				 }
				 
			 {/php}
				
			<nav class="menu" data-ride="menu" style="width: 210px">
			  <ul id="tree_menu" class="tree tree-menu" data-animate="true" data-ride="tree">
			  	{if condition="count($category_list['data']) gt 0"}
			    {foreach $category_list['data'] as $k => $v}
			    <li class="{if $v['category_id'] == $pid}open{/if}">
			      <a href="#"><i class="icon"></i>{$v['category_name']}</a>
			      <ul>
			            {if condition="count($v['child_list']) gt 0"}
					      	{foreach $v['child_list'] as $key => $val}
					        	<li class="{if $val['category_id'] == $category_id}active{/if}"><a href="{:addon_url('Article://web/article/index', ['category_id' => $val['category_id'], 'p_id' => $v['category_id']])}"><i class="icon"></i>{$val['category_name']}</a></li>
					        {/foreach}
			            {/if}
			      </ul>
			    </li>
			    {/foreach}
			    {/if}
			  </ul>
			</nav>
			<input type="hidden" id="category_id" value="{$category_id}">
			<input type="hidden" id="pid" value="{$pid}">
	 </div>
	 
	 <div class="help-content">
	 	<article class="article">
	 	  {if condition="$info['data'] neq ''"}
		  <!-- 文章头部 -->
		  <header>
		    <h1>{$info['data']['title']}</h1>
		    <!-- 文章属性列表 -->
		    <dl class="dl-inline">
		      <dt>
		      	{if $info['data']['source'] != ''}来源：{$info['data']['source']} &nbsp;&nbsp;{/if}
		      	发布时间：{$info['data']['create_time']|date="Y-m-d H:i:s",###}
		      </dt>
		      <dd class="pull-right">
		      	  {if $info['data']['tag'] != ''}
			      <span class="label label-success">{$info['data']['tag']}</span> 
			      {/if}
		      </dd>
		    </dl>
		    {if $info['data']['summary'] != ''}
		    <div class="abstract">
		      <p>摘要：{$info['data']['summary']}</p>
		    </div>
		    {/if}
		  </header>
		  <!-- 文章正文部分 -->
		  <section class="content">
		    {$info['data']['content']}
		  </section>
	      {else /}
		  <div class="empty">还没有相关内容</div>
		  {/if}
		  
		  <!-- 文章底部 -->
		  <footer>
		    <ul class="pager pager-justify">
		      {php}
		      	//上一篇
		      	  $front_params = [
				     'page' => 1,
				     'page_size' => 1,
				     'order' => 'article_id asc',
				     'condition' => json_encode(['article_id' => ['lt', $info['data']['article_id']]]),
				  ];
		      	$front = api('Article.Article.getArticlePageList', $front_params);
		      {/php}
		      {if count($front['data']['list']) != 0}
		      <li class="previous"><a href="{:addon_url('Article://web/article/detail', ['article_id'=>$front['data']['list'][0]['article_id']])}"><i class="icon-arrow-left"></i> 上一篇</a></li>
		      {else }
		      <li class="previous disabled"><a href="#"><i class="icon-arrow-left"></i> 没有上一篇</a></li>
		      {/if}
		      
		      {php}
		      	//下一篇
		      	  $after_params = [
				     'page' => 1,
				     'page_size' => 1,
				     'order' => 'article_id asc',
				     'condition' => json_encode(['article_id' => ['gt', $info['data']['article_id']]]),
				  ];
		      	$after = api('Article.Article.getArticlePageList', $after_params);
		      {/php}
		      {if count($after['data']['list']) != 0}
		      <li class="next"><a href="{:addon_url('Article://web/article/detail', ['article_id'=>$after['data']['list'][0]['article_id']])}">下一篇 <i class="icon-arrow-right"></i></a></li>
		      {else /}
		      <li class="next disabled"><a href="#">没有下一篇 <i class="icon-arrow-right"></i></a></li>
		      {/if}
		    </ul>
		  </footer>
		</article>
	 </div>
	 <div class="clearfix"></div>
	 
 </div>
{/block}
{block name="script"}
{/block}